This vignette demonstrates how to specify the color maps and use data layers by creating a NG-CHM from 2 data layers, each with its own custom color maps.

Color Map (Continuous)

Color maps are created with chmNewColorMap(). The first argument to this function is a list of breakpoints. For the demo data in TCGA.GBM.ExpressionData, most values are between -2 and 2, so we set breakpoints at -2, 0, and 2. The second argument is a corresponding list of colors for those breakpoints. The colors can be specified by name for standard colors, or by hexadecimal code:

library(NGCHM)
colorMap1 <- chmNewColorMap(c(-2,0,2), c('mediumblue','snow','firebrick'))
colorMap2 <- chmNewColorMap(c(-2,0,2), c('#9933ff','#f0f0f0','#228B22'))

Data Layers

Data layers can be created with the chmNewDataLayer() function. The first argument is the desired name of the data layer. The second argument is the matrix of data, and the third argument is the color map.

library(NGCHMDemoData)
dataLayer1 <- chmNewDataLayer('Color Map 1', TCGA.GBM.ExpressionData, colorMap1)
dataLayer2 <- chmNewDataLayer('Color Map 2', TCGA.GBM.ExpressionData, colorMap2)

Creating the NG-CHM

We explicitly provide the two data layers created above to the chmNew() function:

hm <- chmNew('Color Maps', dataLayer1, dataLayer2)

and export to a .ngchm or .html file:

library(NGCHMSupportFiles)
chmExportToFile(hm,'tcga-gbm-color-map.ngchm')
chmExportToHTML(hm,'tcga-gbm-color-map.html')

Resulting NG-CHM

The resulting NG-CHM has the two data layers available. Click on the data layers icon icon to toggle between them.

library('htmltools')
filePath = paste(getwd(),'/tcga-gbm-color-map.html',sep='')
htmltools::includeHTML(filePath)

Back to top